// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

/**
 * Created by eran on 14-12-21.
 */
package gui.component.mapSetting
{
    import com.bit101.components.PushButton;

    import data.DataVoManger;
    import data.MapVo;

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.text.TextField;

    import gui.manger.GUIManger;
    import gui.utils.GUIUtils;

    public class MapSettingLayer
    {
        private var mManger:GUIManger;
        private var mMapSettingLayerMc:MovieClip;

        private var mXTileNumTF:TextField;
        private var mYTileNumTF:TextField;
        private var mSaveBtn:PushButton;

        public function MapSettingLayer()
        {
        }

        //=================================//
        //=== Initialize & Dispose ========//
        //=================================//

        public function initialize(_mapSettingLayerMc:MovieClip, _manger:GUIManger):void
        {
            mMapSettingLayerMc = _mapSettingLayerMc;
            mManger = _manger;

            mXTileNumTF = mMapSettingLayerMc["xTileNumTF"];
            mYTileNumTF = mMapSettingLayerMc["yTileNumTF"];

            mSaveBtn = new PushButton(null, 0, 0, "Change", onClickSaveBtn);
            GUIUtils.replaceTargetWithPH(mSaveBtn, mMapSettingLayerMc["saveBtn"]);

            refresh();
        }

        //=================================//
        //====== Public Function ==========//
        //=================================//

        public function refresh():void
        {
            var mapVo:MapVo = DataVoManger.instance.mapVo;
            mXTileNumTF.text = "" + mapVo.xTileNum;
            mYTileNumTF.text = "" + mapVo.yTileNum;
        }

        //=================================//
        //====== Private Function =========//
        //=================================//

        private function onClickSaveBtn(e:MouseEvent):void
        {
            mManger.onClickSaveMapSettingBtn(int(mXTileNumTF.text), int(mYTileNumTF.text));
        }

    }
}
